export default class Task {
    constructor(next, cbObj) {
        this.next = next
        this.cbObj = cbObj
        this.cbObj.callback = (type) => this.resolve && this.resolve(type)
    }
    cancel(task) {
        task.next(null, null, true)
    }

    /**
     * 将当前的task转换为一个promise对象 结束完成
     * @memberof Task
     */
    toPromise() {
        return new Promise((resolve) => this.resolve = resolve)
    }
}